package com.example.mqttdemo.pojo;

import lombok.Data;

import java.util.List;

@Data
public class ServiceConfig {
    private List<Service> services;

    public static class Service {
        private String service_id;
        private Properties properties;

        // Getter and Setter for service_id
        public String getServiceId() {
            return service_id;
        }

        public void setServiceId(String service_id) {
            this.service_id = service_id;
        }

        // Getter and Setter for properties
        public Properties getProperties() {
            return properties;
        }

        public void setProperties(Properties properties) {
            this.properties = properties;
        }
    }

    @Data
    public static class Properties {
        private String temp = "18°C";
        private boolean ledStatus = true;
        private String airQuality = "60";
        private int humidity = 89;
        private int bright;
        private int airpressure = 1006;
        private boolean airStatus = false;
        private boolean alarmStatus = false;
        private  int airTemp = 24;

        // Getters and Setters for all properties
        // ...

        public void updateProperties(String temp, boolean ledStatus, String airQuality, int humidity, int bright, int airpressure, boolean airStatus, boolean alarmStatus, int airTemp) {
            this.temp = temp;
            this.ledStatus = ledStatus;
            this.airQuality = airQuality;
            this.humidity = humidity;
            this.bright = bright;
            this.airpressure = airpressure;
            this.airStatus = airStatus;
            this.alarmStatus = alarmStatus;
            this.airTemp = airTemp;
        }
    }

    // Method to create a ServiceConfig object with the given service_id and properties
    public static ServiceConfig createServiceConfig(String serviceId, Properties properties) {
        ServiceConfig config = new ServiceConfig();
        Service service = new Service();
        service.setServiceId(serviceId);
        service.setProperties(properties);
        config.setServices(List.of(service));
        return config;
    }
}